﻿@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Form.cshtml";
 }

<form id="form" class="form-horizontal m" role="form" > 
        <div class="form-group">
            <label class="col-sm-3 control-label ">渠道名称<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="name" name="Name" col="Name" type="text" class="form-control required " placeholder="请输入渠道名称" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">省<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="provinceId" name="ProvinceId" col="ProvinceId" type="text" class="form-control required " placeholder="请输入省" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">市<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="cityId" name="CityId" col="CityId" type="text" class="form-control required " placeholder="请输入市" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">区<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="areaId" name="AreaId" col="AreaId" type="text" class="form-control required " placeholder="请输入区" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">详细地址<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="address" name="Address" col="Address" type="text" class="form-control required " placeholder="请输入详细地址" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">备注说明<span class="text-red"> *</span></label>
            <div class="col-sm-9">
                <input id="remark" name="Remark" col="Remark" type="text" class="form-control required " placeholder="请输入备注说明" />
            </div>
        </div>
</form>

<script type="text/javascript">
    var id = frame.request("id");
    $(function () {
        getForm();
    });

    function getForm() {
        if (!!id) {
            frame.ajax({
                url: '@Url.Content("/Sale/ChannelEntity/SetForm")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.success) {
                        $('#form').setWebControls(obj.data);
                    }
                }
            });
        }
        else {
            var defaultData = {};
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            frame.ajax({
                url: '@Url.Content("/Sale/ChannelEntity/SaveForm")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.success) {
                        frame.msgSuccess(obj.message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        frame.msgError(obj.message);
                    }
                }
            });
        }
    }
</script>

